import { QuestionnaireType, QuestionType } from '@/components/question/typing';
import { defineStore } from 'pinia';
export default defineStore('questionnaireStore', {
  state: () => ({}) as QuestionnaireType,
  getters: {
    getBasicInfo: state => {
      return {
        name: state.name,
        language: state.language,
        startDate: state.startDate,
        endDate: state.endDate,
        footer: state.footer,
        mode: state.mode,
        activeQuestionIndex: state.activeQuestionIndex,
        pageTotal: state.pageTotal,
        status: state.status,
      };
    },
    getQuestions: state => state.questions,
    getQuestionnaire: state => state,
  },
  actions: {
    setBasicInfo(basicInfo: QuestionnaireType) {
      this.name = basicInfo.name;
      this.language = basicInfo.language;
      this.startDate = basicInfo.startDate;
      this.endDate = basicInfo.endDate;
      this.footer = basicInfo.footer;
      this.mode = basicInfo.mode;
      this.activeQuestionIndex = basicInfo.activeQuestionIndex;
      this.pageTotal = basicInfo.pageTotal;
      this.status = basicInfo.status;
    },
    setQuestions(questions: Array<QuestionType>) {
      this.questions = questions;
    },
  },
});
